/*
 * DrawindPanelUseCase.java
 *
 * Created on 27 listopad 2008, 21:13
 */

package gui;

import DiagramObjects.DiagramObjects;
import Program.PaintObjects;
import java.util.Vector;
import java.awt.Graphics;
import program.PaintObjects;

/**
 *
 * @author  Administrator
 */
public class DrawindPanelUseCase extends javax.swing.JPanel {
	private PaintObjects PaintObjs;
	private DiagramObjects GeomObjs;
	//private SelectionRect SRect;
	private Vector<Integer> IfSelectedObject;
    /** Creates new form DrawindPanelUseCase */
    public DrawindPanelUseCase() {
		//PaintObjs = new PaintObjects();
		//GeomObjs = new DiagramObjects();
		IfSelectedObject = new Vector<Integer>();
		//SRect = new SelectionRect();

        initComponents();
    }
	public void addSelected()
	{
		IfSelectedObject.add(0);
	}
	
	public void changeSelection(Integer i)
	{
		if (IfSelectedObject.get(i) == 1)
			IfSelectedObject.set(i, 0);
		else
			IfSelectedObject.set(i,1);
		repaint();
		
	}
	
	public void addSelection(Integer i)
	{
			IfSelectedObject.set(i,1);
	}
	
	public void removeSelection(Integer i)
	{
			IfSelectedObject.set(i,0);
	}
	
	public void CleanAllSelections()
	{
		for (int i = 0 ; i < IfSelectedObject.size(); ++i)
		{
			IfSelectedObject.set(i,0);
		}
	}
	
	public Integer getIfElementSelected(Integer i)
	{
		return IfSelectedObject.get(i);
	}
	
	public DiagramObjects GetGeometricObjects()
	{
		return GeomObjs;
	}
  @Override
	public void paintComponent(Graphics g)
	{
		super.paintComponent(g);
		
	// real drawing
		for (int i = 0; i < GeomObjs.GetSize(); ++i) 
		{
			GeomObjs.GetGeometricbjectFromPanel(i).Draw(g, PaintObjs);
			if (IfSelectedObject.get(i) == 1)
				GeomObjs.GetGeometricbjectFromPanel(i).DrawSelection(g, PaintObjs);
			
			SRect.Draw(g, PaintObjs);
			//PaintObjs.DrawGrid(g, 20);
		}
		

		
	
	//}-=-_-=-{ real drawing
	}
	
	public void SetSelectionRect(Integer x, Integer y, Integer w, Integer h)
	{
		SRect.SetSelection(x, y, w, h);
	}
	
	public void ResetSelectionRect()
	{
		SRect.Reset();
	}
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
  private void initComponents() {

    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
    this.setLayout(layout);
    layout.setHorizontalGroup(
      layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGap(0, 400, Short.MAX_VALUE)
    );
    layout.setVerticalGroup(
      layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGap(0, 300, Short.MAX_VALUE)
    );
  }// </editor-fold>//GEN-END:initComponents


  // Variables declaration - do not modify//GEN-BEGIN:variables
  // End of variables declaration//GEN-END:variables

}
